package com.sky.chapter1.waitAndnotify;

/**
 * @author : wushikai
 * <p>
 * date : 2021-03-25
 * 展示 非法 监视器 状态异常
 */
public class IllegalMonitorStateExceptionDemo {



    public  static void waitEx ( )   {

        try {
            System.out.println("报异常!!!");
            new Object().wait();
        } catch (InterruptedException e) {
            e.printStackTrace();

        }


    }

    public  static void waitNEx ( ){

        Object queue = new Object();
        synchronized ( queue ) {

            try {
                System.out.println("不报异常但是死锁!!!");
                queue.wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }


    }


    public static void main(String[] args){

        waitEx();
//        waitNEx();
//
    }

}
